home *** CD-ROM | disk | FTP | other *** search
/ Ian & Stuart's Australian Mac 1 / Ian and Stuart's One (Australia).iso / Australasian Legends / Commercial / Rainbow Hill / MacDOS™ 2.0.0 / batches / extractName.bat < prev    next >
DOS Batch File  |  1994-06-30  |  1KB  |  46 lines

  1. @echo off
  2. !  extractName.bat    Extract a file or folder name from a full DOS path
  3. !
  4. !  extractName path [varName]
  5. !
  6. !  where 'path' is the full path from which the item name is to be extracted
  7. !  and 'varName' is a string containing the name of the global variable into
  8. !  which the item name is to be returned. If 'varName' is missing, extractName
  9. !  displays the name in the console window.
  10. !
  11. !  Copyright © 1994 by Rainbow Hill Pty Ltd. All rights reserved.
  12. !
  13.  
  14.     ! ensure that the first parameter is there and that the third one is not
  15.     set doserr=13
  16.     if not "%3 " == " " goto ERR_LBL
  17.     if "%1 " == " " goto ERR_LBL
  18.  
  19.     ! extract the name into a temporary variable
  20.     set extractName_name=%1
  21.     onerror SKIP_LBL
  22.     sstr/e/r extractName_name "\"
  23. :SKIP_LBL
  24.     onerror SKIP2_LBL
  25.     sstr/e/r extractName_name ":"
  26. :SKIP2_LBL
  27.  
  28.     ! if the second parameter is there, store the name into the requested variable,
  29.     ! otherwise just display the result
  30.     if "%2 " == " " goto DISPLAY_LBL
  31.     set %2=%extractName_name%
  32.     set doserr=0
  33.     goto DONE_LBL
  34.  
  35. :DISPLAY_LBL
  36.     echo %QUOTE%%extractName_name%%QUOTE%
  37.     set doserr=0
  38.     goto DONE_LBL
  39.  
  40. :ERR_LBL
  41.     show %doserr%
  42.  
  43. :DONE_LBL
  44.     ! remove the temporary variable
  45.     set extractName_name=
  46.